--From https://stackoverflow.com/a/20694458
function ordinal_numbers(n)
  local ordinal, digit = {"st", "nd", "rd"}, string.sub(n, -1)
  if tonumber(digit) > 0 and tonumber(digit) <= 3 and string.sub(n,-2) ~= 11 and string.sub(n,-2) ~= 12 and string.sub(n,-2) ~= 13 then
    return n .. ordinal[tonumber(digit)]
  else
    return n .. "th"
  end
end

local t = Def.ActorFrame{


	--[[LoadActor("../DifficultySelect", PLAYER_1)..{
		InitCommand=cmd(zoom,.75);
		OnCommand=cmd(playcommand,"Selected");
	};]]
	
};

local f = Def.ActorFrame{
	InitCommand=cmd(xy,SCREEN_WIDTH-200,0;);
}

--Maybe fix later
local STEPSTYPE = "StepsType_Dance_Single"
for i = 1, 5 do
	f[#f+1] = Def.ActorFrame{
		CurrentSongChangedMessageCommand=function(self)
			local song = GAMESTATE:GetCurrentSong();
			if song then
				if song:HasStepsTypeAndDifficulty(STEPSTYPE,i-1) then
					self:diffuse(Color("White"));
				else
					self:diffuse(color(".5,.5,.5,1"));
				end;
			end;
		end;
		LoadActor("../DifficultySelect/Difflabel (doubleres)")..{
			InitCommand=cmd(zoom,.8;y,55*i;rotationy,180);
		};
		LoadActor(THEME:GetPathG("","ShortStyleText"))..{
			InitCommand=cmd(xy,-130,55*i;animate,false;setstate,i-1;horizalign,left;zoom,1.2;addy,2);
		};
		LoadActor(THEME:GetPathG("","DifficultyIcons"))..{
			InitCommand=cmd(xy,160,55*i;animate,false;setstate,i-1;);
		};
	};
end

f[#f+1] = 	LoadActor(THEME:GetPathG("","1p icon"))..{
		InitCommand=cmd(xy,-150,55-10;visible,GAMESTATE:IsSideJoined(PLAYER_1));
		CurrentStepsP1ChangedMessageCommand=function(self)
			local steps = GAMESTATE:GetCurrentSteps(PLAYER_1)
			if steps then
				local diffNum = Enum.Reverse(Difficulty)[steps:GetDifficulty()];
				--SCREENMAN:SystemMessage(diffNum);
				self:stoptweening():decelerate(.2):y(55*(diffNum+1)-10);
			end;
		end;
	};
	
f[#f+1] = 	LoadActor(THEME:GetPathG("","2p icon"))..{
	InitCommand=cmd(xy,-150,55+10;visible,GAMESTATE:IsSideJoined(PLAYER_2));
	CurrentStepsP2ChangedMessageCommand=function(self)
		local steps = GAMESTATE:GetCurrentSteps(PLAYER_2)
		if steps then
			local diffNum = Enum.Reverse(Difficulty)[steps:GetDifficulty()];
			--SCREENMAN:SystemMessage(diffNum);
			self:stoptweening():decelerate(.2):y(55*(diffNum+1)+10);
		end;
	end;
};

t[#t+1] = f;

t[#t+1] = Def.ActorFrame{
	
	
	--squareGen(253, 2, color("0,0,0,.5"));
	
	Def.Sprite{
		InitCommand=cmd(xy,SCREEN_WIDTH*.8,SCREEN_CENTER_Y+200);
		--InitCommand=cmd(fadeleft,.1;faderight,.1);
		CurrentSongChangedMessageCommand=function(self)
			local song = GAMESTATE:GetCurrentSong();
			if song and song:HasJacket() then
				local jacket = song:GetJacketPath();
				self:Load(jacket);
				self:diffusealpha(1);
			else
				self:diffusealpha(0);
			end;
			self:SetSize(270,270);
			self:stoptweening():zoom(1.2):linear(.1):zoom(1);
		end;
	};
	
	LoadActor("Header")..{
		InitCommand=cmd(Center;zoom,1.333333;addy,-18);
	};
	LoadFont("Serif")..{
		Text=getenv("sMode").." Mode";
		InitCommand=cmd(horizalign,left;vertalign,top;xy,5,10);
	};
	LoadFont("Serif")..{
		InitCommand=cmd(horizalign,left;vertalign,top;xy,5,38;zoom,.9;diffuse,color("#edc0c1"););
		OnCommand=function(self)
			if GAMESTATE:IsEventMode() then
				self:settext("Unlimited Stages");
			else
				--local stg = GAMESTATE:GetCurrentStageIndex() + 1
				self:settext(ordinal_numbers(GAMESTATE:GetCurrentStageIndex() + 1).." Stage")
			end
		end;
	};
};
return t;